package com.infore.siteManagement.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.infore.siteManagement.dto.ItemAndStationDto;
import com.infore.siteManagement.entity.Item;
import com.infore.siteManagement.service.IitemService;
import com.infore.siteManagement.util.ResultEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "项目管理接口--瑞丰", tags = { "项目管理接口--瑞丰" })
@RestController
@RequestMapping("/item")
public class ItemController {

	@Autowired
	private IitemService itemService;

	@ApiOperation(value = "查询项目树接口")
	@ResponseBody
	@GetMapping(value = "/query")
	public ResultEntity query(@RequestParam(value = "name", required = false) String name) {
		return itemService.query(name);
	}

	@ApiOperation(value = "查询项目等级接口")
	@ResponseBody
	@GetMapping(value = "/level")
	public ResultEntity level(@RequestParam(value = "level", required = true) String level) {
		return itemService.level(level);
	}

	@ApiOperation(value = "删除项目通用接口")
	@ApiImplicitParams(@ApiImplicitParam(value = "项目id", name = "ids", paramType = "query", required = true, dataType = "String"))
	@DeleteMapping(value = "/delete")
	public ResultEntity delete(String ids) {
		return itemService.delete(ids);
	}

	@ApiOperation(value = "编辑/新增项目通用接口")
	@ResponseBody
	@PostMapping(value = "/edit")
	public ResultEntity edit(@RequestBody Item item) {
		return itemService.edit(item);
	}

	@ApiOperation(value = "维护站点项目中间表接口")
	@ResponseBody
	@PostMapping(value = "/itemAndStation")
	public ResultEntity itemAndStation(@RequestBody ItemAndStationDto itemAndStationDto) {
		return itemService.itemAndStation(itemAndStationDto);
	}

	@ApiOperation(value = "维护站点项目中间表接口")
	@ResponseBody
	@GetMapping(value = "/queryStation")
	public ResultEntity queryStation(@RequestParam(value = "itemId", required = true) String itemId) {
		return itemService.queryStation(itemId);
	}
}
